<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
//获取请求里的Cookie集合数组
Cookie[] cookies=request.getCookies();
System.out.println("~~~~~~~~~~~~~~~~~~~~~");
System.out.println("长度=="+cookies.length);
String user="";
String time="";
if(cookies!=null){
	for(int i=0;i<cookies.length;i++){
		System.out.println("1=="+new String(cookies[i].getName().getBytes("ISO-8859-1"),"utf-8")); 
		if(cookies[i].getName().equals("myCookie")){
			user=java.net.URLDecoder.decode(cookies[i].getValue().split("#")[0],"UTF-8");
			time=cookies[i].getValue().split("#")[1];
			//System.out.println("2=="+new String(cookies[i].getValue().getBytes("ISO-8859-1"),"utf-8")); 
		} 
		//user=java.net.URLDecoder.decode(cookies[i].getValue(),"UTF-8");
		/* System.out.print(java.net.URLDecoder.decode(cookies[i].getValue(),"UTF-8"));
		System.out.print(new String("黄刈".getBytes("ISO-8859-1"),"UTF-8")); */
	}
	if("".equals(user)&&"".equals(time)){
		%>
		欢迎游客初次光临本店
		<form action="writeCookie.jsp" method="get"><!-- 指定提交目标 -->
		<input type="text" name="user" value="">
		<input type="submit" value="提交">
		</form>
		<script type="text/javascript">
		</script>
		<%
		System.out.print("第一次登陆!");
		}else{
		%>
		欢迎<%=user %>再次光临本店,<br>您上次来是在<%=time %>
		<%
		System.out.print("第二次登陆!");
		}
}
		%>
</body>
</html>